<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :offset="7" :xs="10" :sm="10" :md="10" :lg="10" :xl="10">
        <el-form ref="form" :model="operationData" label-width="150px">
          <el-form-item label="一键施肥费用:" :rules="rule" prop="num1">
            <el-input v-model="operationData.fertilizerAllReduce" type="num1" style="float: left; width: 250px;"></el-input>
            <p style="float: left; margin-left:10px">(小康币)</p>
          </el-form-item>
          <el-form-item label="一键捉虫费用:" :rules="rule" prop="num2">
            <el-input v-model="operationData.catchAllReduce" type="num2" style="float: left; width: 250px;"></el-input>
            <p style="float: left; margin-left:10px">(小康币)</p>
          </el-form-item>
          <el-form-item label="一键浇水费用:" :rules="rule" prop="num3">
            <el-input v-model="operationData.waterAllReduce" type="num3" style="float: left; width: 250px;"></el-input>
            <p style="float: left; margin-left:10px">(小康币)</p>
          </el-form-item>
          <el-form-item label="一键播种费用:" :rules="rule" prop="num4">
            <el-input v-model="operationData.sowAllReduce" type="num4" style="float: left; width: 250px;"></el-input>
            <p style="float: left; margin-left:10px">(小康币)</p>
          </el-form-item>
          <el-form-item label="一键收割费用:" :rules="rule" prop="num5">
            <el-input v-model="operationData.pickAllReduce" type="num5" style="float: left; width: 250px;"></el-input>
            <p style="float: left; margin-left:10px">(小康币)</p>
          </el-form-item>  
        </el-form>
      </el-col>
    </el-row>
    <el-button type="primary" style="display:block;margin:70px auto" @click="setOperation">立即创建</el-button>
  </div>
</template>

<script>
  // 异步请求 delLly
  import {
    getOperation,
    setOperation
  } from '../../../../api/game/farmReq.js'
  import Vue from 'vue'
  //引用富文本
  import { getToken } from '@/utils/auth'
  export default {
    data() {
      return {
        operationData: {},
        rule: [
          // {
          //   required: true,
          //   message: '不能为空'
          // },
          {
            type: 'number',
            message: '必须为数字值'
          }
        ]
      }
    },
    created() {
      // this.getList()
      this.getOperation()
    },
    methods: {

      // 获取一键费用
      getOperation() {
        getOperation({}).then(res => {
          console.log('canshu', res.data)
          this.operationData = res.data
        })
      },
      // 设置
      setOperation(e) {
        let operationList = []
        operationList.push({
          operateName: 'PICK_ALL',
          reduceXkb: this.operationData.pickAllReduce
        })
        operationList.push({
          operateName: 'WATER_ALL',
          reduceXkb: this.operationData.waterAllReduce
        })
        operationList.push({
          operateName: 'FERTILIZER_ALL',
          reduceXkb: this.operationData.fertilizerAllReduce
        })
        operationList.push({
          operateName: 'CATCHS_ALL',
          reduceXkb: this.operationData.catchAllReduce
        })
        operationList.push({
          operateName: 'SOW_ALL',
          reduceXkb: this.operationData.sowAllReduce
        })
        console.log(operationList)

        setOperation(JSON.stringify(operationList)).then(res => {
          console.log('shezhi', res.data)
          this.operationData = res.data
          this.getOperation()
        })
      }

    }
  }
</script>
<style scoped>
  .el-row {
    margin-bottom: 20px;
  }

  .fs {
    display: flex;

  }
</style>
